﻿using CKS.PLC.Core;
using CKS.PLC.Core.Siemens;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZR.Infrastructure.Helper;


namespace CKS.PLC.Core.Event
{
    public static class EventBus
    {
        /// <summary>
        /// 当错误状态变更触发
        /// </summary>

        public static event Action<ISiemensClient, int> OnPlcHeart;

        public static event Action<string> OnPLCUpdate;

        public static ConcurrentQueue<string> logQueues = new ConcurrentQueue<string>();
        internal static void PlcHeart(ISiemensClient plcClient, int plcHeartValue)
        {
            OnPlcHeart?.Invoke(plcClient, plcHeartValue);
        }
        public static void AddLog(string msg)
        {
            LogHelper.WritePlcLog(msg);
            msg = DateTime.Now.ToString("MM/dd HH:mm:ss") + " " + msg;
            logQueues.Enqueue(msg);
           
        }
    }
}
